<template>
	<view class="bed-page">
		<view class="bed-row flex">
			<view class="bed-col">
				<view class="btn plus-btn" @click="openUrl('/pages/ucenter/addBed')">
					<u-icon name="plus-circle-fill" size="40" color="#fff"></u-icon>
					<view class="bed-title">
						添加床位
					</view>
				</view>
			</view>
			<view class="bed-col">
				<view class="btn minus-btn">
					<u-icon name="minus-circle-fill" size="40" color="#fff"></u-icon>
					<view class="bed-title">
						删除床位
					</view>
				</view>
			</view>
		</view>
		<view class="bed-cells">
			<u-row gutter="20">
				<u-checkbox-group @change="checkboxGroupChange" width="40rpx" active-color='#12d08a'>
					<u-col span="4" v-for="(item, index) in list" :key="index">
						<view class="bed-card">
							<view class="bed-hd flex-center">
								<u-checkbox @change="checkboxChange" v-model="item.checked" :name="item.name" size="40"
									shape="circle" v-if="item.status != '占用'">
								</u-checkbox>
								<view class="nn">{{item.name}}</view>
							</view>
							<view class="bed-bar">
								<view class="box"><text>类型：</text>
									<view class="bed-status">{{item.type}}</view>
								</view>
								<view class="box"><text>状态：</text>
									<view class="bed-status warning" v-if="item.status == '占用'">{{item.status}}</view>
									<view class="bed-status success" v-else>{{item.status}}</view>
								</view>
							</view>
						</view>
					</u-col>
				</u-checkbox-group>
			</u-row>
			<view class="bed-foot">
				<button type="default" class="btn check-btn" @click="checkedAll">全选</button>
				<button type="default" class="btn del-btn" @click="handelete">删除</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						name: '1床',
						checked: false,
						type: '固定',
						status: '占用'
					},
					{
						name: '2床',
						checked: false,
						type: '固定',
						status: '占用'
					},
					{
						name: '3床',
						checked: false,
						type: '固定',
						status: '占用'
					},
					{
						name: '4床',
						checked: true,
						type: '固定',
						status: '空闲'
					},
					{
						name: '5床',
						checked: true,
						type: '固定',
						status: '空闲'
					},
					{
						name: '6床',
						checked: true,
						type: '固定',
						status: '空闲'
					},
					{
						name: '7床',
						checked: false,
						type: '固定',
						status: '空闲'
					},
					{
						name: '8床',
						checked: false,
						type: '固定',
						status: '空闲'
					},
					{
						name: '9床',
						checked: false,
						type: '固定',
						status: '空闲'
					}
				]
			}
		},
		onLoad() {

		},
		methods: {
			openUrl(e) {
				console.log(e)
				uni.navigateTo({
					url: e
				});
			},
			checkedAll() {
				this.list.map(val => {
					val.checked = true;
				})
			},
			handelete(){
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.bed-page {
		padding: 20rpx 30rpx;

		.bed-row {
			margin: 0 -15rpx;

			.bed-col {
				width: 50%;
				float: left;
				padding: 0 15rpx;

				.bed-bg {
					height: 100%;
					width: 100%;
					display: block;
				}

				.btn {
					border-radius: 12rpx;
					height: 190rpx;
					position: relative;
					display: flex;
					align-items: center;
					justify-content: center;


					.u-icon {
						margin-right: 12rpx;
					}

					.bed-title {
						font-size: 36rpx;
						color: #fff;
						line-height: 40rpx;
					}
				}

				.plus-btn {
					background-image: linear-gradient(90deg, #1baefc, #4294ff);
					box-shadow: 10rpx 13rpx 16rpx rgba(7, 147, 243, 0.23);

					.u-icon {
						box-shadow: 4rpx 5rpx 10rpx rgba(0, 97, 172, 0.1);
					}
				}

				.minus-btn {
					background-image: linear-gradient(90deg, #ff9006, #f4c52f);
					box-shadow: 10rpx 13rpx 16rpx rgba(229, 144, 0, 0.23);

					.u-icon {
						box-shadow: 4rpx 5rpx 10rpx rgba(231, 137, 0, 0.1);
					}
				}

				.btn::after {
					display: none;
				}
			}
		}
	}

	.bed-cells {
		padding: 30rpx 0;
		margin: 0 -10rpx;

		.bed-hd {

			.nn {
				color: #596371;
				font-size: 32rpx;
				height: 42rpx;
				margin-left: 12rpx;
				line-height: 42rpx;
			}
		}

	}

	.bed-card {
		background-color: #fff;
		border-radius: 12rpx;
		padding: 20rpx 20rpx 10rpx;
		margin-bottom: 20rpx;
		height: 200rpx;

		.bed-bar {
			margin-top: 20rpx;

			.box {
				display: flex;
				align-items: center;
				line-height: 36rpx;
				color: #596371;
				font-size: 20rpx;
				margin-bottom: 20rpx;
			}

			.bed-status {
				color: #fff;
				background-color: #2c8ce2;
				border-radius: 6rpx;
				height: 36rpx;
				padding: 0 10rpx;
				position: relative;
				z-index: 11;
			}

			.warning {
				background-color: #fdaa20;
			}

			.success {
				background-color: #00d689;
			}

			.danger {
				background-color: #ff1d28;
			}
		}
	}

	.bed-foot {
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 80rpx;

		.btn {
			width: 260rpx;
			height: 70rpx;
			margin: 0 40rpx;
			padding: 10rpx;
			border-radius: 35rpx;
			line-height: 50rpx;
			font-size: 30rpx;
			color: #fff;
		}

		.btn::after {
			display: none;
		}

		.check-btn {
			background-color: #258ee9;
		}

		.del-btn {
			background-color: #ff1d28;
		}
	}
</style>
